package com.sds.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Util_DB {
	private final static String DB_CLASS_NAME = "oracle.jdbc.driver.OracleDriver";
	private final static String DB_URL = "jdbc:oracle:thin:@localhost:1521:XE";
	private final static String DB_ID = "SDS";
	private final static String DB_PW = "SDS";

	public static Connection connection() {
		Connection conn = null;

		try {
			Class.forName(DB_CLASS_NAME);
			conn = DriverManager.getConnection(DB_URL, DB_ID, DB_PW);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return conn;
	}

	public static void disconnection(ResultSet rs, PreparedStatement pstmt,
			Connection conn) {
		try {
			if (rs != null)
				rs.close();

		} catch (Exception e) {
		}

		try {
			if (pstmt != null)
				pstmt.close();
		} catch (Exception e) {
		}
		try {
			if (conn != null)
				conn.close();
		} catch (Exception e) {
		}

	}

}